<template>
  <view v-if="shenheStatus == 0" class="i-qrcode flex-row">
    <image @click="onClick" class="img" :src="qrcode"></image>
  </view>
  <Shenhe v-else-if="shenheStatus == 1"></Shenhe>
</template>

<script>
import Shenhe from "@/components/shenhe/shenhe";
import shareApi from "@/api/share.js";

export default {
  components: { Shenhe },
  data() {
    return {
      qrcode: "",
    };
  },
  onLoad() {
    uni.setNavigationBarTitle({
      title: this.$t("title.shareQrcode"),
    });
    this.getData();
  },
  methods: {
    async getData() {
      const res = await shareApi.getQrcode({});
      if (res.code == 0) {
        // 判断是分销商
        if (!res.status) {
          this.qrcode = res.data;
        } else {
          uni.showModal({
            title: "提示",
            content: res.msg,
            showCancel:false,
            confirmText:'知道啦',
            confirmColor: '#3CC51F',
            success:({confirm})=>{
             confirm && this.$utils.goBack()
            },
          });
        }
      }
    },
    onClick: function () {
      uni.previewImage({
        current: 0,
        urls: [this.qrcode],
      });
    },
  },
};
</script>

<style scoped>
.i-qrcode {
  width: 100%;
  height: 1200rpx;
}

.i-qrcode .img {
  width: 100%;
  height: 100%;
  background-size: 100% 100%;
}
</style>
